﻿using System;
using System.Linq;
using System.Text;
using DevExpress.Xpo;
using DevExpress.ExpressApp;
using System.ComponentModel;
using DevExpress.ExpressApp.DC;
using DevExpress.Data.Filtering;
using DevExpress.Persistent.Base;
using System.Collections.Generic;
using DevExpress.ExpressApp.Model;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;

namespace aztall.Module.BusinessObjects
{
	[DefaultProperty("FileName"), FileAttachment("File")]
	public class PromoAttachment : DomainObject
	{
		protected Promo _Promo;
		protected FileData _File;
		protected int _Size;
		protected string _FileName;

		public PromoAttachment(Session session)
				: base(session)
		{
		}
		public override void AfterConstruction()
		{
			base.AfterConstruction();

		}

		[Association("Promo_PromoAttachments", UseAssociationNameAsIntermediateTableName = true), XafDisplayName("Promotion")]
		public Promo Promo
		{
			get { return _Promo; }
			set { SetPropertyValue<Promo>(nameof(Promo), ref _Promo, value); }
		}
		public FileData File
		{
			get { return _File; }
			set { SetPropertyValue(nameof(File), ref _File, value); }
		}
		[ToolTip("File size in bytes.")]
		public int Size
		{
			get { return File?.Size ?? 0; }
		}
	}
}
